<?php
	include(ROOTPATH .'include'. DS .'protect.php');
	include ROOTPATH .'include'. DS .'isMyQuery.php';
	$do				= getQuery('do')  ;
	$page			= getPage('page');
	$file_id		= getId('file_id');
	
	
	
	
	

switch($do){
	case 'getFile' 	: getFile($file_id , $page) ;
	break;

}


function getFile($file_id , $page = 1 ){
	global $dbs ;
	$sql = 'SELECT * FROM `'.DB_PRE.'file` WHERE `id` = '. $file_id ;
	$lists = $dbs -> select($sql);
	foreach($lists as $list){
		$files 		= explode('|',$list['file']);
		$fileTitles = explode( SPLIT_STRING ,$list['fileTitles']);
		
		$file 		= $files[$page-1];
		$title		= $fileTitles[$page-1];
		$size 		= explode(',',$file);
		$size 		= explode('.',$size[1]);
		$size 		= explode('x',$size[0]);
		$width		= $size[0];							
		$height 	= $size[1]; 
		$fileType 	= getFileExt($file);
		if( $fileType == 'jpg' || $fileType == 'png' || $fileType == 'gif')
			$fileType = 'img';
		if( $fileType = 'img' )
			$msg = json_encode('<img src="'.$file.'" width="'.$width.'" height="'.$height.'" />');
		else
			$msg = $file  ;
		exit('{"status":"ok","fileType":"'. $fileType .'","msg":'.$msg.',"title":'. json_encode($title).'}');
	}
}
	
	
?>